package gatoropoly.ui;

import gatoropoly.game.Gatoropoly;
import gatoropoly.game.Player;
import gatoropoly.peer.PlayerPeer;

import java.awt.GridLayout;

import javax.swing.JPanel;

import modelz.ui.PeerMap;
import modelz.ui.PeerMapListener;


public class PlayerList extends JPanel implements PeerMapListener<PlayerPeer> {

	private static final long serialVersionUID = 6009335074727417445L;

	private PeerMap<Player, PlayerPeer> playerPeers;

	public PlayerList(Gatoropoly client) {
		super();
		playerPeers = new PeerMap<Player, PlayerPeer>(client, client.getState()
				.players(), PlayerPeer.class);
		playerPeers.addListener(this);
		setLayout(new GridLayout(0, 1));
	}

	public void itemAdded(PlayerPeer item) {
		add(item.getComponent());
	}

	public void itemRemoved(PlayerPeer item) {
		remove(item.getComponent());
	}

}
